let config = {
  apps : [{
    name        : "node_shells",
    script      : "./bin/www",
    log_date_format  : "YYYY-MM-DD HH:mm:SS",
    log_file   : "logs/pm2.log",
    error_file : "logs/pm2-err.log",
    out_file   : "logs/pm2-out.log",
    pid_file   : "logs/pm2.pid",
    exec_mode  : "fork",
    instances  : "1",
    watch      :  true,
    ignore_watch : ["logs/*", "node_modules/*", "uploads/*"]
  }]
}

let debug_mode = false;
for(let arg of process.argv) {
  if(arg == '-debug') {
    debug_mode = true;
    break;
  }
}

if(debug_mode) {
  console.log('== launching in debug mode ==');
  config.apps[0].node_args = "--debug=0.0.0.0:5858";
}
else {
  console.log('== launching in production mode ==');
  config.apps[0].node_args = " ";   //*require! or it will always uses latest debug options
}

module.exports = config;